package com.bigkoo.pickerview.view;

import android.view.View;

import com.bigkoo.pickerview.R;
import com.bigkoo.pickerview.adapter.ArrayWheelAdapter;
import com.bigkoo.pickerview.adapter.NumericWheelAdapter;
import com.bigkoo.pickerview.lib.WheelView;
import com.bigkoo.pickerview.listener.OnItemSelectedListener;
import com.bigkoo.pickerview.utils.ChinaDate;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


public class WheelTime {
    public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
    
    private View view;
    @SuppressWarnings("rawtypes")
    private WheelView wv_year;
    @SuppressWarnings("rawtypes")
    private WheelView wv_month;
    @SuppressWarnings("rawtypes")
    private WheelView wv_day;
    private WheelView<Integer> wv_hours;
    private WheelView<Integer> wv_mins;
    private WheelView<Integer> wv_seconds;
    private int gravity;
    
    private final boolean[] type;
    private static final int DEFAULT_START_YEAR = 1900;
    private static final int DEFAULT_END_YEAR = 2100;
    private static final int DEFAULT_START_MONTH = 1;
    private static final int DEFAULT_END_MONTH = 12;
    private static final int DEFAULT_START_DAY = 1;
    private static final int DEFAULT_END_DAY = 31;
    private static final int DEFAULT_START_HOUR = 0;
    private static final int DEFAULT_END_HOUR = 23;
    private static final int DEFAULT_START_MIN = 0;
    private static final int DEFAULT_END_MIN = 59;
    private static final int DEFAULT_START_SECOND = 0;
    private static final int DEFAULT_END_SECOND = 59;
    
    private Calendar startDate;
    private Calendar endDate;
    private int startYear = DEFAULT_START_YEAR;
    private int endYear = DEFAULT_END_YEAR;
    private int startMonth = DEFAULT_START_MONTH;
    private int endMonth = DEFAULT_END_MONTH;
    private int startDay = DEFAULT_START_DAY;
    private int endDay = DEFAULT_END_DAY; //表示31天的
    private int startHour = DEFAULT_START_HOUR;
    private int endHour = DEFAULT_END_HOUR;
    private int startMin = DEFAULT_START_MIN;
    private int endMin = DEFAULT_END_MIN;
    private int startSecond = DEFAULT_START_SECOND;
    private int endSecond = DEFAULT_END_SECOND;
    private int currentYear;
    
    // 根据屏幕密度来指定选择器字体的大小(不同屏幕可能不同)
    private int textSize = 18;
    // 未选中文字大小
    private int textOutSize = 18;
    // 文字的颜色和分割线的颜色
    private int textColorOut;
    private int textColorCenter;
    private int dividerColor;
    // 条目间距倍数
    private float lineSpacingMultiplier = 1.6F;
    
    private WheelView.DividerType dividerType;
    
    private int lunarStartYear;
    private int lunarEndYear;
    private int lunarStartMonth;
    private int lunarEndMonth;
    private boolean lunarStartMonthIsLeap;
    private boolean lunarEndMonthIsLeap;
    private int lunarStartDay;
    private int lunarEndDay;
    
    
    /**
     * 是否是农历
     */
    private boolean isLunarCalendar = false;
    
    /**
     * 大月
     */
    private List<String> month_big;
    
    /**
     * 小月
     */
    private List<String> month_little;
    
    public WheelTime(View view) {
        super();
        this.view = view;
        type = new boolean[]{true, true, true, true, true, true};
        setView(view);
        init();
    }
    
    public WheelTime(View view, boolean[] type, int gravity, int textSize) {
        this(view, type, gravity, textSize, textSize);
    }
    
    public WheelTime(View view, boolean[] type, int gravity, int textSize, int textOutSize) {
        super();
        this.view = view;
        this.type = type;
        this.gravity = gravity;
        this.textSize = textSize;
        this.textOutSize = textOutSize;
        setView(view);
        init();
    }
    
    private void init() {
        this.startDate = Calendar.getInstance();
        this.startDate.set(DEFAULT_START_YEAR,
            DEFAULT_START_MONTH,
            DEFAULT_START_DAY,
            DEFAULT_START_HOUR,
            DEFAULT_START_MIN,
            DEFAULT_START_SECOND);
        
        this.endDate = Calendar.getInstance();
        this.endDate.set(DEFAULT_END_YEAR,
            DEFAULT_END_MONTH,
            DEFAULT_END_DAY,
            DEFAULT_END_HOUR,
            DEFAULT_END_MIN,
            DEFAULT_END_SECOND);
        
        // 添加大小月月份并将其转换为list,方便之后的判断
        String[] months_big = {"1", "3", "5", "7", "8", "10", "12"};
        String[] months_little = {"4", "6", "9", "11"};
        month_big = Arrays.asList(months_big);
        month_little = Arrays.asList(months_little);
    }
    
    public void setLunarCalendar(boolean isLunarCalendar) {
        this.isLunarCalendar = isLunarCalendar;
    }
    
    public boolean isLunarCalendar() {
        return isLunarCalendar;
    }
    
    /**
     * 超过上下限，则取上下限值
     */
    public void setPicker(@NonNull Calendar date) {
        if (date.getTime().getTime() < startDate.getTime().getTime()) {
            date = startDate;
        } else if (date.getTime().getTime() > endDate.getTime().getTime()) {
            date = endDate;
        }
        
        int year = date.get(Calendar.YEAR);
        int month = date.get(Calendar.MONTH) + 1;
        int day = date.get(Calendar.DAY_OF_MONTH);
        int hour = date.get(Calendar.HOUR_OF_DAY);
        int minute = date.get(Calendar.MINUTE);
        int seconds = date.get(Calendar.SECOND);
        
        if (isLunarCalendar) {
            int[] ints = ChinaDate.solarToLunar(year, month, day);
            setLunar(ints[0], ints[1], ints[2], ints[3] != 0, hour, minute, seconds);
        } else {
            setSolar(year, month, day, hour, minute, seconds);
        }
    }
    
    // <editor-fold desc="公历">
    
    /**
     * 设置公历
     *
     * @param month 此处的month范围是0~11(0:1月，11:12月)，而本地设置的时间是从1~12，因此以下逻辑，对于month都会加1
     */
    @SuppressWarnings("unchecked")
    private void setSolar(int year, int month, int day, int h, int m, int s) {
        if (type.length != 6) {
            throw new IllegalArgumentException("type[] length is not 6");
        }
        
        currentYear = year;
        // 年
        wv_year = view.findViewById(R.id.year);
        // 设置"年"的显示数据
        wv_year.setAdapter(new NumericWheelAdapter(startYear, endYear));
        wv_year.setCurrentItem(year - startYear);// 初始化时显示的数据
        wv_year.setGravity(gravity);
        
        // 月
        wv_month = view.findViewById(R.id.month);
        setReMonth(year, month, false);
        wv_month.setGravity(gravity);
        
        
        // 日
        wv_day = view.findViewById(R.id.day);
        setReDay(year, month, day, false);
        wv_day.setGravity(gravity);
        
        
        // 时
        wv_hours = view.findViewById(R.id.hour);
        setReHour(year, month, day, h, false);
        wv_hours.setGravity(gravity);
        
        
        //分
        wv_mins = view.findViewById(R.id.min);
        setReMin(year, month, day, h, m, false);
        wv_mins.setGravity(gravity);
        
        
        // 秒
        wv_seconds = view.findViewById(R.id.second);
        setReSecond(year, month, day, h, m, s);
        wv_seconds.setGravity(gravity);
        
        wv_year.setOnItemSelectedListener(wheelListener_year);
        wv_month.setOnItemSelectedListener(wheelListener_month);
        wv_day.setOnItemSelectedListener(wheelListener_day);
        wv_hours.setOnItemSelectedListener(wheelListener_hour);
        wv_mins.setOnItemSelectedListener(wheelListener_min);
        
        wv_year.setVisibility(type[0] ? View.VISIBLE : View.GONE);
        wv_month.setVisibility(type[1] ? View.VISIBLE : View.GONE);
        wv_day.setVisibility(type[2] ? View.VISIBLE : View.GONE);
        wv_hours.setVisibility(type[3] ? View.VISIBLE : View.GONE);
        wv_mins.setVisibility(type[4] ? View.VISIBLE : View.GONE);
        wv_seconds.setVisibility(type[5] ? View.VISIBLE : View.GONE);
        setContentTextSize();
        setOutTextSize();
    }
    
    /**
     * "年"监听
     */
    private final OnItemSelectedListener wheelListener_year = new OnItemSelectedListener() {
        @Override
        public void onItemSelected(int index) {
            currentYear = index + startYear;
            //noinspection ConstantConditions
            setReMonth(currentYear, (int) wv_month.getCurrentItem(), true);
        }
    };
    
    /**
     * "月"监听
     */
    private final OnItemSelectedListener wheelListener_month = new OnItemSelectedListener() {
        @Override
        public void onItemSelected(int index) {
            //noinspection ConstantConditions
            setReDay(currentYear,
                (int) wv_month.getCurrentItem(),
                (int) wv_day.getCurrentItem(), true);
        }
    };
    
    /**
     * "天"监听
     */
    private final OnItemSelectedListener wheelListener_day = new OnItemSelectedListener() {
        @SuppressWarnings("ConstantConditions")
        @Override
        public void onItemSelected(int index) {
            //noinspection ConstantConditions
            setReHour(currentYear,
                (int) wv_month.getCurrentItem(),
                (int) wv_day.getCurrentItem(),
                wv_hours.getCurrentItem(), true);
        }
    };
    
    /**
     * "小时"监听
     */
    private final OnItemSelectedListener wheelListener_hour = new OnItemSelectedListener() {
        @SuppressWarnings("ConstantConditions")
        @Override
        public void onItemSelected(int index) {
            setReMin(currentYear,
                (int) wv_month.getCurrentItem(),
                (int) wv_day.getCurrentItem(),
                wv_hours.getCurrentItem(),
                wv_mins.getCurrentItem(), true);
        }
    };
    
    /**
     * "分钟"监听
     */
    private final OnItemSelectedListener wheelListener_min = new OnItemSelectedListener() {
        @SuppressWarnings("ConstantConditions")
        @Override
        public void onItemSelected(int index) {
            setReSecond(currentYear,
                (int) wv_month.getCurrentItem(),
                (int) wv_day.getCurrentItem(),
                wv_hours.getCurrentItem(),
                wv_mins.getCurrentItem(),
                wv_seconds.getCurrentItem());
        }
    };
    
    /**
     * 根据年份重新设置月份可筛选范围
     *
     * @param year        当前选中年份
     * @param selectMonth 当前选中月份
     * @param resetDay    是否要根据月份重新设置天筛选范围
     */
    @SuppressWarnings({"unchecked", "ConstantConditions"})
    private void setReMonth(int year, int selectMonth, boolean resetDay) {
        if (startYear == endYear) {
            // 开始年等于终止年
            wv_month.setAdapter(new NumericWheelAdapter(startMonth, endMonth));
        } else if (year == startYear) {
            // 起始日期的月份控制
            wv_month.setAdapter(new NumericWheelAdapter(startMonth, DEFAULT_END_MONTH));
        } else if (year == endYear) {
            // 终止日期的月份控制
            wv_month.setAdapter(new NumericWheelAdapter(DEFAULT_START_MONTH, endMonth));
        } else {
            wv_month.setAdapter(new NumericWheelAdapter(DEFAULT_START_MONTH, DEFAULT_END_MONTH));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_month.getAdapter();
        int indexOf = adapter.indexOf(selectMonth);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_month.getAdapter().getItemsCount() - 1;
        }
        wv_month.setCurrentItem(indexOf);
        
        if (resetDay) {
            int month = (int) wv_month.getCurrentItem();
            int day = (int) wv_day.getCurrentItem();
            setReDay(currentYear, month, day, resetDay);
        }
    }
    
    /**
     * 根据月份重新设置日期可筛选范围
     *
     * @param year        当前选中的年份
     * @param month       当前选中的月份
     * @param selectedDay 当前选中的日期
     * @param resetHour   是否要重置小时筛选范围
     */
    @SuppressWarnings({"unchecked", "ConstantConditions"})
    private void setReDay(int year, int month, int selectedDay, boolean resetHour) {
        // 是否是闰年
        boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
        if (startYear == endYear && startMonth == endMonth) {
            if (month_big.contains(String.valueOf(month))) {
                if (endDay > 31) {
                    endDay = 31;
                }
                wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay));
            } else if (month_little.contains(String.valueOf(month))) {
                if (endDay > 30) {
                    endDay = 30;
                }
                wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay));
            } else {
                // 闰年
                if (isLeapYear) {
                    if (endDay > 29) {
                        endDay = 29;
                    }
                } else {
                    if (endDay > 28) {
                        endDay = 28;
                    }
                }
                wv_day.setAdapter(new NumericWheelAdapter(startDay, endDay));
            }
        } else if (year == startYear && month == startMonth) {
            // 起始日期的天数控制
            if (month_big.contains(String.valueOf(month))) {
                wv_day.setAdapter(new NumericWheelAdapter(startDay, 31));
            } else if (month_little.contains(String.valueOf(month))) {
                wv_day.setAdapter(new NumericWheelAdapter(startDay, 30));
            } else {
                // 闰年
                if (isLeapYear) {
                    wv_day.setAdapter(new NumericWheelAdapter(startDay, 29));
                } else {
                    
                    wv_day.setAdapter(new NumericWheelAdapter(startDay, 28));
                }
            }
        } else if (year == endYear && month == endMonth) {
            // 终止日期的天数控制
            if (month_big.contains(String.valueOf(month))) {
                if (endDay > 31) {
                    endDay = 31;
                }
                wv_day.setAdapter(new NumericWheelAdapter(1, endDay));
            } else if (month_little.contains(String.valueOf(month))) {
                if (endDay > 30) {
                    endDay = 30;
                }
                wv_day.setAdapter(new NumericWheelAdapter(1, endDay));
            } else {
                // 闰年
                if (isLeapYear) {
                    if (endDay > 29) {
                        endDay = 29;
                    }
                } else {
                    if (endDay > 28) {
                        endDay = 28;
                    }
                }
                wv_day.setAdapter(new NumericWheelAdapter(1, endDay));
            }
        } else {
            // 判断大小月及是否闰年,用来确定"日"的数据
            if (month_big.contains(String.valueOf(month))) {
                wv_day.setAdapter(new NumericWheelAdapter(1, 31));
            } else if (month_little.contains(String.valueOf(month))) {
                wv_day.setAdapter(new NumericWheelAdapter(1, 30));
            } else {
                // 闰年
                if (isLeapYear) {
                    wv_day.setAdapter(new NumericWheelAdapter(1, 29));
                } else {
                    wv_day.setAdapter(new NumericWheelAdapter(1, 28));
                }
            }
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_day.getAdapter();
        int indexOf = adapter.indexOf(selectedDay);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_day.getAdapter().getItemsCount() - 1;
        }
        wv_day.setCurrentItem(indexOf);
        
        if (resetHour) {
            int day = (int) wv_day.getCurrentItem();
            int hour = wv_hours.getCurrentItem();
            setReHour(year, month, day, hour, resetHour);
        }
    }
    
    /**
     * 根据日期份重新设置小时可筛选范围
     *
     * @param year         当前选中的年份
     * @param month        当前选中的月份
     * @param day          当前选中的日期
     * @param selectedHour 当前选中的小时
     * @param resetMin     是否要重置分钟筛选范围
     */
    @SuppressWarnings("ConstantConditions")
    private void setReHour(int year, int month, int day, int selectedHour, boolean resetMin) {
        if (startYear == endYear && startMonth == endMonth && startDay == endDay) {
            wv_hours.setAdapter(new NumericWheelAdapter(startHour, endHour));
        } else if (year == startYear && month == startMonth && day == startDay) {
            wv_hours.setAdapter(new NumericWheelAdapter(startHour, DEFAULT_END_HOUR));
        } else if (year == endYear && month == endMonth && day == endDay) {
            wv_hours.setAdapter(new NumericWheelAdapter(DEFAULT_START_HOUR, endHour));
        } else {
            wv_hours.setAdapter(new NumericWheelAdapter(DEFAULT_START_HOUR, DEFAULT_END_HOUR));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_hours.getAdapter();
        int indexOf = adapter.indexOf(selectedHour);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_hours.getAdapter().getItemsCount() - 1;
        }
        wv_hours.setCurrentItem(indexOf);
        
        if (resetMin) {
            int hour = wv_hours.getCurrentItem();
            int min = wv_mins.getCurrentItem();
            setReMin(year, month, day, hour, min, resetMin);
        }
    }
    
    /**
     * 根据小时重新设置分钟可筛选范围
     *
     * @param year        当前选中的年份
     * @param month       当前选中的月份
     * @param day         当前选中的日期
     * @param hour        当前选中的小时
     * @param selectedMin 当前选中分钟
     * @param resetSecond 是否要重置秒筛选范围
     */
    @SuppressWarnings("ConstantConditions")
    private void setReMin(int year, int month, int day, int hour, int selectedMin, boolean resetSecond) {
        if (startYear == endYear && startMonth == endMonth && startDay == endDay && startHour == endHour) {
            wv_mins.setAdapter(new NumericWheelAdapter(startMin, endMin));
        } else if (year == startYear && month == startMonth && day == startDay && hour == startHour) {
            wv_mins.setAdapter(new NumericWheelAdapter(startMin, DEFAULT_END_MIN));
        } else if (year == endYear && month == endMonth && day == endDay && hour == endHour) {
            wv_mins.setAdapter(new NumericWheelAdapter(DEFAULT_START_MIN, endMin));
        } else {
            wv_mins.setAdapter(new NumericWheelAdapter(DEFAULT_START_MIN, DEFAULT_END_MIN));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_mins.getAdapter();
        int indexOf = adapter.indexOf(selectedMin);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_mins.getAdapter().getItemsCount() - 1;
        }
        wv_mins.setCurrentItem(indexOf);
        
        if (resetSecond) {
            int min = wv_mins.getCurrentItem();
            int second = wv_seconds.getCurrentItem();
            setReSecond(year, month, day, hour, min, second);
        }
    }
    
    /**
     * 根据分钟重新设置秒可筛选范围
     *
     * @param year           当前选中的年份
     * @param month          当前选中的月份
     * @param day            当前选中的日期
     * @param hour           当前选中的小时
     * @param min            当前选中分钟
     * @param selectedSecond 当前选中秒
     */
    private void setReSecond(int year, int month, int day, int hour, int min, int selectedSecond) {
        if (startYear == endYear && startMonth == endMonth && startDay == endDay && startHour == endHour && startMin == endMin) {
            wv_seconds.setAdapter(new NumericWheelAdapter(startSecond, endSecond));
        } else if (year == startYear && month == startMonth && day == startDay && hour == startHour && min == startMin) {
            wv_seconds.setAdapter(new NumericWheelAdapter(startSecond, DEFAULT_END_SECOND));
        } else if (year == endYear && month == endMonth && day == endDay && hour == endHour && min == endMin) {
            wv_seconds.setAdapter(new NumericWheelAdapter(DEFAULT_START_SECOND, endSecond));
        } else {
            wv_seconds.setAdapter(new NumericWheelAdapter(DEFAULT_START_SECOND, DEFAULT_END_SECOND));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_seconds.getAdapter();
        int indexOf = adapter.indexOf(selectedSecond);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_seconds.getAdapter().getItemsCount() - 1;
        }
        wv_seconds.setCurrentItem(indexOf);
    }
    // </editor-fold>
    
    
    // <editor-fold desc="阴历">
    
    /**
     * 设置农历
     *
     * @param year  农历年
     * @param month 农历月，1—12
     * @param day   农历天
     */
    private void setLunar(int year, int month, int day, boolean isLeap, int h, int m, int s) {
        if (type.length != 6) {
            throw new RuntimeException("type[] length is not 6");
        }
        
        // 年
        currentYear = year;
        wv_year = view.findViewById(R.id.year);
        // 设置"年"的显示数据
        //noinspection unchecked
        wv_year.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getYears(lunarStartYear, lunarEndYear)));
        // 添加文字
        wv_year.setLabel("");
        // 初始化时显示的数据
        wv_year.setCurrentItem(year - lunarStartYear);
        wv_year.setGravity(gravity);
        
        // 月
        wv_month = view.findViewById(R.id.month);
        setReLunarMonth(year, month, isLeap, false);
        wv_month.setLabel("");
        wv_month.setGravity(gravity);
        
        // 日
        wv_day = view.findViewById(R.id.day);
        setReLunarDay(year, month, day, ChinaDate.getLeapMonth(year) != 0, false);
        wv_day.setLabel("");
        wv_day.setGravity(gravity);
        
        wv_hours = view.findViewById(R.id.hour);
        setReLunarHour(year, month, day, h, false);
        wv_hours.setGravity(gravity);
        
        wv_mins = view.findViewById(R.id.min);
        setReLunarMin(year, month, day, h, m, false);
        wv_mins.setGravity(gravity);
        
        wv_seconds = view.findViewById(R.id.second);
        setReLunarSecond(year, month, day, h, m, s);
        wv_seconds.setGravity(gravity);
        
        // 添加"年"监听
        wv_year.setOnItemSelectedListener(wheelListener_lunar_year);
        // 添加"月"监听
        wv_month.setOnItemSelectedListener(wheelListener_lunar_month);
        // 添加"日"监听
        wv_day.setOnItemSelectedListener(wheelListener_lunar_day);
        // 添加"时"监听
        wv_hours.setOnItemSelectedListener(wheelListener_lunar_hour);
        // 添加"分"监听
        wv_mins.setOnItemSelectedListener(wheelListener_lunar_min);
        
        wv_year.setVisibility(type[0] ? View.VISIBLE : View.GONE);
        wv_month.setVisibility(type[1] ? View.VISIBLE : View.GONE);
        wv_day.setVisibility(type[2] ? View.VISIBLE : View.GONE);
        wv_hours.setVisibility(type[3] ? View.VISIBLE : View.GONE);
        wv_mins.setVisibility(type[4] ? View.VISIBLE : View.GONE);
        wv_seconds.setVisibility(type[5] ? View.VISIBLE : View.GONE);
        setContentTextSize();
        setOutTextSize();
    }
    
    /**
     * 根据年重新设置月份可筛选区间
     *
     * @param year     当前选中的农历年
     * @param month    当前选中的农历月，1-12
     * @param isLeap   month是否是闰月
     * @param resetDay 是否重新设置天的筛选范围
     */
    @SuppressWarnings({"unchecked", "ConstantConditions"})
    private void setReLunarMonth(int year, int month, boolean isLeap, boolean resetDay) {
        if (year == lunarStartYear && year == lunarEndYear) {
            wv_month.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getMonths(year, lunarStartMonth, lunarStartMonthIsLeap, lunarEndMonth, lunarEndMonthIsLeap)));
        } else if (year == lunarStartYear) {
            wv_month.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getMonths(year, lunarStartMonth, lunarStartMonthIsLeap, 12, true)));
        } else if (year == lunarEndYear) {
            wv_month.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getMonths(year, 1, false, lunarEndMonth, lunarEndMonthIsLeap)));
        } else {
            wv_month.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getMonths(year, 1, false, 12, true)));
        }
        
        ArrayWheelAdapter<String> adapter = (ArrayWheelAdapter<String>) wv_month.getAdapter();
        int indexOf;
        if (isLeap) {
            indexOf = adapter.indexOf("闰" + ChinaDate.nStr1[month] + "月");
        } else {
            indexOf = adapter.indexOf(ChinaDate.nStr1[month] + "月");
        }
        
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_month.getAdapter().getItemsCount() - 1;
        }
        wv_month.setCurrentItem(indexOf);
        
        if (resetDay) {
            month = getLunarSelectedMonth()[0];
            int day = getLunarSelectedDay();
            setReLunarDay(year, month, day, isLeap, resetDay);
        }
    }
    
    /**
     * 根据月重新设置日期可筛选区间
     *
     * @param year      当前选中的农历年
     * @param month     当前选中的农历月，1-12
     * @param isLeap    month是否是闰月
     * @param day       当前选中的农历天
     * @param resetHour 是否重新设置小时的筛选范围
     */
    @SuppressWarnings({"unchecked", "ConstantConditions"})
    private void setReLunarDay(int year, int month, int day, boolean isLeap, boolean resetHour) {
        if (lunarStartYear == lunarEndYear && lunarStartMonth == lunarEndMonth) {
            wv_day.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getLunarDays(lunarStartDay, lunarEndDay)));
        } else if (year == lunarEndYear && month == lunarEndMonth) {
            wv_day.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getLunarDays(1, lunarEndDay)));
        } else {
            int maxDay;
            if (isLeap) {
                // 选中闰月
                maxDay = ChinaDate.getLeapMonthDays(year);
            } else {
                maxDay = ChinaDate.getMonthDays(year, month);
            }
            
            int minDay;
            if (year == lunarStartYear && month == lunarStartMonth) {
                minDay = lunarStartDay;
            } else {
                minDay = 1;
            }
            
            wv_day.setAdapter(new ArrayWheelAdapter<>(ChinaDate.getLunarDays(minDay, maxDay)));
        }
        
        ArrayWheelAdapter<String> adapter = (ArrayWheelAdapter<String>) wv_day.getAdapter();
        int indexOf = adapter.indexOf(ChinaDate.getChinaDay(day));
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_day.getAdapter().getItemsCount() - 1;
        }
        wv_day.setCurrentItem(indexOf);
        
        if (resetHour) {
            day = getLunarSelectedDay();
            int hour = wv_hours.getCurrentItem();
            setReLunarHour(year, month, day, hour, resetHour);
        }
    }
    
    /**
     * 根据日期重新设置小时可筛选范围
     *
     * @param year     当前选中的农历年份
     * @param month    当前选中的农历月份，1-12
     * @param day      当前选中的农历日期
     * @param hour     当前选中的小时
     * @param resetMin 是否要重置分钟筛选范围
     */
    @SuppressWarnings("ConstantConditions")
    private void setReLunarHour(int year, int month, int day, int hour, boolean resetMin) {
        if (lunarStartYear == lunarEndYear && lunarStartMonth == lunarEndMonth && lunarStartDay == lunarEndDay) {
            wv_hours.setAdapter(new NumericWheelAdapter(startHour, endHour));
        } else if (year == lunarStartYear && month == lunarStartMonth && day == lunarStartDay) {
            wv_hours.setAdapter(new NumericWheelAdapter(startHour, DEFAULT_END_HOUR));
        } else if (year == lunarEndYear && month == lunarEndMonth && day == endDay) {
            wv_hours.setAdapter(new NumericWheelAdapter(DEFAULT_START_HOUR, lunarEndDay));
        } else {
            wv_hours.setAdapter(new NumericWheelAdapter(DEFAULT_START_HOUR, DEFAULT_END_HOUR));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_hours.getAdapter();
        int indexOf = adapter.indexOf(hour);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_hours.getAdapter().getItemsCount() - 1;
        }
        wv_hours.setCurrentItem(indexOf);
        
        if (resetMin) {
            hour = wv_hours.getCurrentItem();
            int min = wv_mins.getCurrentItem();
            setReLunarMin(year, month, day, hour, min, resetMin);
        }
    }
    
    /**
     * 根据日期重新设置小时可筛选范围
     *
     * @param year        当前选中的农历年份
     * @param month       当前选中的农历月份，1-12
     * @param day         当前选中的农历日期
     * @param hour        当前选中的小时
     * @param resetSecond 是否要重置秒的筛选范围
     */
    @SuppressWarnings("ConstantConditions")
    private void setReLunarMin(int year, int month, int day, int hour, int min, boolean resetSecond) {
        if (lunarStartYear == lunarEndYear && lunarStartMonth == lunarEndMonth
            && lunarStartDay == lunarEndDay && startHour == endHour) {
            wv_mins.setAdapter(new NumericWheelAdapter(startMin, endMin));
        } else if (year == lunarStartYear && month == lunarStartMonth && day == lunarStartDay && hour == startHour) {
            wv_mins.setAdapter(new NumericWheelAdapter(startMin, DEFAULT_END_MIN));
        } else if (year == lunarEndYear && month == lunarEndMonth && day == lunarEndDay && hour == endHour) {
            wv_mins.setAdapter(new NumericWheelAdapter(DEFAULT_START_MIN, endMin));
        } else {
            wv_mins.setAdapter(new NumericWheelAdapter(DEFAULT_START_MIN, DEFAULT_END_MIN));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_mins.getAdapter();
        int indexOf = adapter.indexOf(min);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_mins.getAdapter().getItemsCount() - 1;
        }
        wv_mins.setCurrentItem(indexOf);
        
        if (resetSecond) {
            min = wv_mins.getCurrentItem();
            setReLunarSecond(year, month, day, hour, min, wv_seconds.getCurrentItem());
        }
    }
    
    /**
     * 根据分钟重新设置秒可筛选范围
     *
     * @param year   当前选中的农历年份
     * @param month  当前选中的农历月份，1-12
     * @param day    当前选中的农历日期
     * @param hour   当前选中的小时
     * @param min    当前选中分钟
     * @param second 当前选中秒
     */
    private void setReLunarSecond(int year, int month, int day, int hour, int min, int second) {
        if (lunarStartYear == lunarEndYear && lunarStartMonth == lunarEndMonth
            && lunarStartDay == lunarEndDay && startHour == endHour && startMin == endMin) {
            wv_seconds.setAdapter(new NumericWheelAdapter(startSecond, endSecond));
        } else if (year == lunarStartYear && month == lunarStartMonth && day == lunarStartDay && hour == startHour && min == startMin) {
            wv_seconds.setAdapter(new NumericWheelAdapter(startSecond, DEFAULT_END_SECOND));
        } else if (year == lunarEndYear && month == lunarEndMonth && day == lunarEndDay && hour == endHour && min == endMin) {
            wv_seconds.setAdapter(new NumericWheelAdapter(DEFAULT_START_SECOND, endSecond));
        } else {
            wv_seconds.setAdapter(new NumericWheelAdapter(DEFAULT_START_SECOND, DEFAULT_END_SECOND));
        }
        
        NumericWheelAdapter adapter = (NumericWheelAdapter) wv_seconds.getAdapter();
        int indexOf = adapter.indexOf(second);
        if (indexOf == -1) {
            indexOf = 0;
        } else if (indexOf > adapter.getItemsCount() - 1) {
            indexOf = wv_seconds.getAdapter().getItemsCount() - 1;
        }
        wv_seconds.setCurrentItem(indexOf);
    }
    
    /**
     * "年"监听
     */
    private final OnItemSelectedListener wheelListener_lunar_year = new OnItemSelectedListener() {
        @Override
        public void onItemSelected(int index) {
            currentYear = index + lunarStartYear;
            int[] lunarSelectedMonth = getLunarSelectedMonth();
            setReLunarMonth(currentYear, lunarSelectedMonth[0], lunarSelectedMonth[1] != 0, true);
        }
    };
    
    /**
     * "月"监听
     */
    private final OnItemSelectedListener wheelListener_lunar_month = new OnItemSelectedListener() {
        @Override
        public void onItemSelected(int index) {
            String monthStr = (String) wv_month.getCurrentItem();
            boolean isLeap = monthStr != null && monthStr.contains("闰");
            int month = monthStr == null ? 0 : ChinaDate.chinaMonthToInt(monthStr.replace("闰", "").replace("月", ""));
            String dayStr = (String) wv_day.getCurrentItem();
            int day = ChinaDate.chinaDayToInt(dayStr);
            setReLunarDay(currentYear, month, day, isLeap, true);
        }
    };
    
    /**
     * "天"监听
     */
    @SuppressWarnings("ConstantConditions")
    private final OnItemSelectedListener wheelListener_lunar_day = index -> {
        int[] lunarSelectedMonth = getLunarSelectedMonth();
        int day = getLunarSelectedDay();
        setReLunarHour(currentYear, lunarSelectedMonth[0], day, wv_hours.getCurrentItem(), true);
    };
    
    /**
     * "小时"监听
     */
    private final OnItemSelectedListener wheelListener_lunar_hour = new OnItemSelectedListener() {
        @SuppressWarnings("ConstantConditions")
        @Override
        public void onItemSelected(int index) {
            int[] lunarSelectedMonth = getLunarSelectedMonth();
            int day = getLunarSelectedDay();
            setReLunarHour(currentYear, lunarSelectedMonth[0], day, wv_hours.getCurrentItem(), true);
        }
    };
    
    /**
     * "分钟"监听
     */
    private final OnItemSelectedListener wheelListener_lunar_min = new OnItemSelectedListener() {
        @SuppressWarnings("ConstantConditions")
        @Override
        public void onItemSelected(int index) {
            int[] lunarSelectedMonth = getLunarSelectedMonth();
            int day = getLunarSelectedDay();
            setReLunarMin(currentYear, lunarSelectedMonth[0], day, wv_hours.getCurrentItem(),
                wv_mins.getCurrentItem(), true);
        }
    };
    
    /**
     * 选择的月份
     *
     * @return int[0] : month : 1-12 ,int[1]: 是否是闰月
     */
    private int[] getLunarSelectedMonth() {
        String monthStr = (String) wv_month.getCurrentItem();
        if (monthStr == null) {
            return new int[]{0, 0};
        }
        
        boolean isLeap = monthStr.contains("闰");
        int month = ChinaDate.chinaMonthToInt(monthStr.replace("闰", "").replace("月", ""));
        return new int[]{month, isLeap ? 1 : 0};
    }
    
    /**
     * 选择的日期
     */
    private int getLunarSelectedDay() {
        String dayStr = (String) wv_day.getCurrentItem();
        return ChinaDate.chinaDayToInt(dayStr);
    }
    
    /**
     * 农历返回对应的公历时间
     */
    private String getLunarTime() {
        StringBuilder sb = new StringBuilder();
        int[] lunarSelectedMonth = getLunarSelectedMonth();
        int lunarSelectedDay = getLunarSelectedDay();
        int[] solar = ChinaDate.lunarToSolar(currentYear, lunarSelectedMonth[0], lunarSelectedDay, lunarSelectedMonth[1] == 1);
        
        int hour = wv_hours.getCurrentIndex();
        int mins = wv_mins.getCurrentIndex();
        int seconds = wv_seconds.getCurrentIndex();
        sb.append(solar[0]).append("-")
            .append(solar[1] < 9 ? "0" + solar[1] : solar[1]).append("-")
            .append(solar[2] < 9 ? "0" + solar[2] : solar[2]).append(" ")
            .append(hour < 9 ? "0" + hour : hour).append(":")
            .append(mins < 9 ? "0" + mins : mins).append(":")
            .append(seconds < 9 ? "0" + seconds : seconds);
        return sb.toString();
    }
    // </editor-fold>
    
    
    private void setContentTextSize() {
        wv_day.setTextSize(textSize);
        wv_month.setTextSize(textSize);
        wv_year.setTextSize(textSize);
        wv_hours.setTextSize(textSize);
        wv_mins.setTextSize(textSize);
        wv_seconds.setTextSize(textSize);
    }
    
    private void setOutTextSize() {
        wv_day.setTextOutSize(textOutSize);
        wv_month.setTextOutSize(textOutSize);
        wv_year.setTextOutSize(textOutSize);
        wv_hours.setTextOutSize(textOutSize);
        wv_mins.setTextOutSize(textOutSize);
        wv_seconds.setTextOutSize(textOutSize);
    }
    
    private void setTextColorOut() {
        wv_day.setTextColorOut(textColorOut);
        wv_month.setTextColorOut(textColorOut);
        wv_year.setTextColorOut(textColorOut);
        wv_hours.setTextColorOut(textColorOut);
        wv_mins.setTextColorOut(textColorOut);
        wv_seconds.setTextColorOut(textColorOut);
    }
    
    private void setTextColorCenter() {
        wv_day.setTextColorCenter(textColorCenter);
        wv_month.setTextColorCenter(textColorCenter);
        wv_year.setTextColorCenter(textColorCenter);
        wv_hours.setTextColorCenter(textColorCenter);
        wv_mins.setTextColorCenter(textColorCenter);
        wv_seconds.setTextColorCenter(textColorCenter);
    }
    
    private void setDividerColor() {
        wv_day.setDividerColor(dividerColor);
        wv_month.setDividerColor(dividerColor);
        wv_year.setDividerColor(dividerColor);
        wv_hours.setDividerColor(dividerColor);
        wv_mins.setDividerColor(dividerColor);
        wv_seconds.setDividerColor(dividerColor);
    }
    
    private void setDividerType() {
        
        wv_day.setDividerType(dividerType);
        wv_month.setDividerType(dividerType);
        wv_year.setDividerType(dividerType);
        wv_hours.setDividerType(dividerType);
        wv_mins.setDividerType(dividerType);
        wv_seconds.setDividerType(dividerType);
        
    }
    
    private void setLineSpacingMultiplier() {
        wv_day.setLineSpacingMultiplier(lineSpacingMultiplier);
        wv_month.setLineSpacingMultiplier(lineSpacingMultiplier);
        wv_year.setLineSpacingMultiplier(lineSpacingMultiplier);
        wv_hours.setLineSpacingMultiplier(lineSpacingMultiplier);
        wv_mins.setLineSpacingMultiplier(lineSpacingMultiplier);
        wv_seconds.setLineSpacingMultiplier(lineSpacingMultiplier);
    }
    
    public void setLabels(String label_year, String label_month, String label_day, String label_hours, String label_mins, String label_seconds) {
        if (!isLunarCalendar) {
            if (label_year != null) {
                wv_year.setLabel(label_year);
            } else {
                wv_year.setLabel(view.getContext().getString(R.string.pickerview_year));
            }
            if (label_month != null) {
                wv_month.setLabel(label_month);
            } else {
                wv_month.setLabel(view.getContext().getString(R.string.pickerview_month));
            }
            if (label_day != null) {
                wv_day.setLabel(label_day);
            } else {
                wv_day.setLabel(view.getContext().getString(R.string.pickerview_day));
            }
        }
        
        if (label_hours != null) {
            wv_hours.setLabel(label_hours);
        } else {
            wv_hours.setLabel(view.getContext().getString(R.string.pickerview_hours));
        }
        if (label_mins != null) {
            wv_mins.setLabel(label_mins);
        } else {
            wv_mins.setLabel(view.getContext().getString(R.string.pickerview_minutes));
        }
        if (label_seconds != null) {
            wv_seconds.setLabel(label_seconds);
        } else {
            wv_seconds.setLabel(view.getContext().getString(R.string.pickerview_seconds));
        }
        
    }
    
    public void setTextXOffset(int xoffset_year, int xoffset_month, int xoffset_day, int xoffset_hours, int xoffset_mins, int xoffset_seconds) {
        wv_year.setTextXOffset(-xoffset_year);
        wv_month.setTextXOffset(-xoffset_month);
        wv_day.setTextXOffset(-xoffset_day);
        wv_hours.setTextXOffset(-xoffset_hours);
        wv_mins.setTextXOffset(-xoffset_mins);
        wv_seconds.setTextXOffset(-xoffset_seconds);
    }
    
    /**
     * 设置是否循环滚动
     */
    public void setCyclic(boolean cyclic) {
        wv_year.setCyclic(cyclic);
        wv_month.setCyclic(cyclic);
        wv_day.setCyclic(cyclic);
        wv_hours.setCyclic(cyclic);
        wv_mins.setCyclic(cyclic);
        wv_seconds.setCyclic(cyclic);
    }
    
    @Nullable
    public Date getDate() {
        try {
            return DATE_FORMAT.parse(getTime());
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }
    
    /**
     * 返回选中的日期，格式: yyyy-MM-dd HH:mm:ss
     */
    @SuppressWarnings("ConstantConditions")
    private String getTime() {
        if (isLunarCalendar) {
            // 如果是农历 返回对应的公历时间
            return getLunarTime();
        }
        
        StringBuilder sb = new StringBuilder();
        int year = (int) wv_year.getAdapter().getItem(wv_year.getCurrentIndex());
        int month = (int) wv_month.getAdapter().getItem(wv_month.getCurrentIndex());
        int day = (int) wv_day.getAdapter().getItem(wv_day.getCurrentIndex());
        int hour = wv_hours.getAdapter().getItem(wv_hours.getCurrentIndex());
        int mins = wv_mins.getAdapter().getItem(wv_mins.getCurrentIndex());
        int seconds = wv_seconds.getAdapter().getItem(wv_seconds.getCurrentIndex());
        sb.append(year).append("-")
            .append(month < 9 ? "0" + month : month).append("-")
            .append(day < 9 ? "0" + day : day).append(" ")
            .append(hour < 9 ? "0" + hour : hour).append(":")
            .append(mins < 9 ? "0" + mins : mins).append(":")
            .append(seconds < 9 ? "0" + seconds : seconds);
        return sb.toString();
    }
    
    public View getView() {
        return view;
    }
    
    public void setView(View view) {
        this.view = view;
    }
    
    public void setRangDate(Calendar startDate, Calendar endDate) {
        if (startDate == null && endDate != null) {
            this.startDate = Calendar.getInstance();
            this.startDate.set(DEFAULT_START_YEAR,
                DEFAULT_START_MONTH,
                DEFAULT_START_DAY,
                DEFAULT_START_HOUR,
                DEFAULT_START_MIN,
                DEFAULT_START_SECOND);
            this.endDate = endDate;
            
            int year = endDate.get(Calendar.YEAR);
            int month = endDate.get(Calendar.MONTH) + 1;
            int day = endDate.get(Calendar.DAY_OF_MONTH);
            int hour = endDate.get(Calendar.HOUR_OF_DAY);
            int min = endDate.get(Calendar.MINUTE);
            int second = endDate.get(Calendar.SECOND);
            if (year > startYear) {
                initEndTime(year, month, day, hour, min, second);
            } else if (year == startYear) {
                if (month > startMonth) {
                    initEndTime(year, month, day, hour, min, second);
                } else if (month == startMonth) {
                    if (day > startDay) {
                        initEndTime(year, month, day, hour, min, second);
                    } else if (day == startDay) {
                        if (hour > startHour) {
                            initEndTime(year, month, day, hour, min, second);
                        } else if (hour == startHour) {
                            if (min > startMin) {
                                initEndTime(year, month, day, hour, min, second);
                            } else if (min == startMin) {
                                if (second > startSecond) {
                                    initEndTime(year, month, day, hour, min, second);
                                }
                            }
                        }
                    }
                }
            }
            
        } else if (startDate != null && endDate == null) {
            this.endDate = Calendar.getInstance();
            this.endDate.set(DEFAULT_END_YEAR,
                DEFAULT_END_MONTH,
                DEFAULT_END_DAY,
                DEFAULT_END_HOUR,
                DEFAULT_END_MIN,
                DEFAULT_END_SECOND);
            this.startDate = startDate;
            
            int year = startDate.get(Calendar.YEAR);
            int month = startDate.get(Calendar.MONTH) + 1;
            int day = startDate.get(Calendar.DAY_OF_MONTH);
            int hour = startDate.get(Calendar.HOUR_OF_DAY);
            int min = startDate.get(Calendar.MINUTE);
            int second = startDate.get(Calendar.SECOND);
            if (year < endYear) {
                initStartTime(year, month, day, hour, min, second);
            } else if (year == endYear) {
                if (month < endMonth) {
                    initStartTime(year, month, day, hour, min, second);
                } else if (month == endMonth) {
                    if (day < endDay) {
                        initStartTime(year, month, day, hour, min, second);
                    } else if (day == endDay) {
                        if (hour < endHour) {
                            initStartTime(year, month, day, hour, min, second);
                        } else if (hour == endHour) {
                            if (min < endMin) {
                                initStartTime(year, month, day, hour, min, second);
                            } else if (min == endMin) {
                                if (second < endSecond) {
                                    initStartTime(year, month, day, hour, min, second);
                                }
                            }
                        }
                    }
                }
            }
        } else if (startDate != null) {
            if (startDate.getTimeInMillis() > endDate.getTimeInMillis()) {
                throw new IllegalArgumentException("The end time must be greater than or equal to the start time");
            }
            
            this.startDate = startDate;
            this.endDate = endDate;
            
            initStartTime(startDate.get(Calendar.YEAR),
                startDate.get(Calendar.MONTH) + 1,
                startDate.get(Calendar.DAY_OF_MONTH),
                startDate.get(Calendar.HOUR_OF_DAY),
                startDate.get(Calendar.MINUTE),
                startDate.get(Calendar.SECOND));
            
            initEndTime(endDate.get(Calendar.YEAR),
                endDate.get(Calendar.MONTH) + 1,
                endDate.get(Calendar.DAY_OF_MONTH),
                endDate.get(Calendar.HOUR_OF_DAY),
                endDate.get(Calendar.MINUTE),
                endDate.get(Calendar.SECOND));
        }
        
        int[] lunarStartDate = ChinaDate.solarToLunar(startYear, startMonth, startDay);
        int[] lunarEndDate = ChinaDate.solarToLunar(endYear, endMonth, endDay);
        lunarStartYear = lunarStartDate[0];
        lunarStartMonth = lunarStartDate[1];
        lunarStartDay = lunarStartDate[2];
        lunarStartMonthIsLeap = lunarStartDate[3] == 1;
        lunarEndYear = lunarEndDate[0];
        lunarEndMonth = lunarEndDate[1];
        lunarEndDay = lunarEndDate[2];
        lunarEndMonthIsLeap = lunarEndDate[3] == 1;
    }
    
    /**
     * 获取可选日期范围的开始时间
     */
    public Calendar getStartDate() {
        return startDate;
    }
    
    /**
     * 获取可选日期范围的结束时间
     */
    public Calendar getEndDate() {
        return endDate;
    }
    
    private void initEndTime(int year, final int month, int day, int hour, int min, int second) {
        this.endYear = year;
        this.endMonth = month;
        this.endDay = day;
        this.endHour = hour;
        this.endMin = min;
        this.endSecond = second;
    }
    
    private void initStartTime(int year, final int month, int day, int hour, int min, int second) {
        this.startYear = year;
        this.startMonth = month;
        this.startDay = day;
        this.startHour = hour;
        this.startMin = min;
        this.startSecond = second;
    }
    
    /**
     * 设置间距倍数,但是只能在1.0-2.0f之间
     */
    public void setLineSpacingMultiplier(float lineSpacingMultiplier) {
        this.lineSpacingMultiplier = lineSpacingMultiplier;
        setLineSpacingMultiplier();
    }
    
    /**
     * 设置分割线的颜色
     */
    public void setDividerColor(int dividerColor) {
        this.dividerColor = dividerColor;
        setDividerColor();
    }
    
    /**
     * 设置分割线的类型
     */
    public void setDividerType(WheelView.DividerType dividerType) {
        this.dividerType = dividerType;
        setDividerType();
    }
    
    /**
     * 设置分割线之间的文字的颜色
     */
    public void setTextColorCenter(int textColorCenter) {
        this.textColorCenter = textColorCenter;
        setTextColorCenter();
    }
    
    /**
     * 设置分割线以外文字的颜色
     */
    public void setTextColorOut(int textColorOut) {
        this.textColorOut = textColorOut;
        setTextColorOut();
    }
    
    /**
     * Label 是否只显示中间选中项的
     */
    
    public void isCenterLabel(Boolean isCenterLabel) {
        wv_day.isCenterLabel(isCenterLabel);
        wv_month.isCenterLabel(isCenterLabel);
        wv_year.isCenterLabel(isCenterLabel);
        wv_hours.isCenterLabel(isCenterLabel);
        wv_mins.isCenterLabel(isCenterLabel);
        wv_seconds.isCenterLabel(isCenterLabel);
    }
}
